package com.sxj.corejava.code19_静态代理;

public class UserServiceProxy2 implements UserService{

    private UserService userService = new UserServiceImpl();

    @Override
    public String login(String username, String password) {
        System.out.println("开启事务");
        String value = null;
        try {
            value = userService.login(username,password);
            System.out.println("提交事务");
        } catch (Exception e) {
            System.out.println("回滚事务");
        }

        return value;
    }

    @Override
    public void register(String username, String password) {
        System.out.println("开启事务");
        try {
            userService.register(username,password);
            int i = 1 / 0;
            System.out.println("提交事务");
        } catch (Exception e) {
            System.out.println("回滚事务");
        }
    }
}
